﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Lola.Datos.Persistencia
{
    public static class pChofer
    {
        public static Chofer buscarChofer(int legajo)
        {
            using (SeminarioIEntities contextSeminarioI = new SeminarioIEntities())
            {
                var query = from p in contextSeminarioI.Chofers
                            where p.legajo == legajo
                            select p;
                Chofer ch = query.First();
                return ch;
            }
        }

        public static List<Chofer> buscarChoferes()
        {
            List<Chofer> result = new List<Chofer>();

            using (SeminarioIEntities contextSeminarioI = new SeminarioIEntities())
            {
                IEnumerable<Chofer> chs = from p in contextSeminarioI.Chofers
                                          
                                          select p;

                foreach (Chofer ch in chs)
                {
                    result.Add(ch);
                }
            }
            return result;
        }

        public static List<Chofer> buscarChoferesPorServicio(String codigoServicio)
        {
            List<Chofer> res = new List<Chofer>();
            using (SeminarioIEntities con = new SeminarioIEntities())
            {
                var q = from c in con.ChoferServicios
                        where c.Servicio.cod.Equals(codigoServicio)
                        select c.Chofer;
                foreach (Chofer ch in q)
                {
                    res.Add(ch);
                }

            }
            return res;

        }

    }
}
